package com.iceberg.adgt.ui.architecture;

import com.iceberg.adgt.domain.UnitDTO;

import javax.swing.*;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

/**
 * @author David
 */
public final class UnitListModel extends AbstractListModel {

	private final List<UnitDTO> units;

	public UnitListModel(Set<UnitDTO> units) {
		this.units = new LinkedList<UnitDTO>(units);
	}

	@Override
	public int getSize() {
		return units.size();
	}

	@Override
	public Object getElementAt(int index) {
		return "<<" + units.get(index).getType().getName() + ">>: " + this.units.get(index).getName();
	}

	public UnitDTO getUnitAt(int index) {
		return this.units.get(index);
	}

}
